#include <stdio.h>
#include <stdlib.h>

#include "main.h"
#include "cli.h"

int cli_update_data(FILE* out){
  static double real_inte_value;
  static double real_freq_value;
  static double note_freq_value;
  static const char* note_name;
  static unsigned char note_octa_value;
  static double delta_value;
  
  switch(main_produce(&real_inte_value, &real_freq_value, &note_freq_value, &note_name, &note_octa_value, &delta_value)){
  case 0:
    fprintf(out, "Level: %f\n", real_inte_value);
    fflush(out);
    break;
  case 1:
    fprintf(out, "Level: %f, Real Freq: %.3f, Note Freq: %.3f, Note: %s, Octave: %d, Delta: %.2f\n", real_inte_value, real_freq_value, note_freq_value, note_name, note_octa_value, delta_value);
    fflush(out);
    break;
  }
}

int cli_main(){
  main_activate();
  
  for(;;) cli_update_data(stdout);
  
  main_deactive();
  
  return 0;
}
